package com.lagou.rabbit.controller;

import com.lagou.rabbit.po.Order;
import com.lagou.rabbit.util.OrderUtil;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * created by wq at 2020/12/13
 */
@RestController
@RequestMapping("/delayPayment")
public class PaymentController {

    @PostMapping("/pay/{id}")
    public Boolean payment(@PathVariable String id) {
        // 修改订单状态
        Order order = OrderUtil.get(id);
        if (Objects.nonNull(order)) {
            order.setStatus("已支付");
            OrderUtil.add(order);
            return true;
        }
        return false;
    }
}
